<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试</title>
    
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>

    <script type="text/javascript">
    var ul = document.querySelector('ul');
    var list = document.querySelectorAll('li');
    ul.onclick = (e) =>{
        list.forEach((item,index)=>{
            if(e.taget === item){
                console.log(item,index)
            }
        })
    }
    
        
    
    
        
        // 1.递归求50年薪资
        /* function dep(wage,year){
            if (year<=50){
                return dep(wage*(1+0.005),++year);
            }
            return wage;
        }
        console.log(dep(10,1));  */

        // 2.利用欧几里得算法（辗转相除法）编写一个函数gcd(x,y) 求最大公约数，编写一个函数lcm(x,y)求最小公倍数

        // 最大公约数：两个整数的最大公约数等于其中较小的那个数和两数相除余数的最大公约数
        /* function gcd(num1,num2){
            var temp;
            if(num1<num2){  // 互换
                temp = num2;
                num2 = num1;
                num1 = temp;
            }
            while(num2 != 0){
                temp = num2;
                num2 = num1%num2;
                num1 = temp;
            }
            return num1;
        }
        console.log(gcd(1997,615)); */

        // 最小公倍数：gcd(x, y) * lcm(x, y) == x * y
        /* function lcm(num1,num2){
            return (num1*num2)/gcd(num1,num2)
        }

        console.log(lcm(1997,615)); */
        
        
    </script>
</body>
</html>